import cv2
import numpy as np
from argparse import ArgumentParser


def denoise_avg(img, kernel_size):
    result = cv2.medianBlur(img, kernel_size)
    return result


def main(option):
    img = cv2.imread(option.input_file, cv2.IMREAD_GRAYSCALE)
    img = denoise_avg(img, option.kernel_size)
    cv2.imwrite(option.output_file, img)


if __name__ == '__main__':
    parser = ArgumentParser()
    parser.add_argument('--input_file', type=str, default='output/noise/speckle_alpha=30.00_beta=30.00.bmp')
    parser.add_argument('--output_file', type=str, default='output/denoise/median/speckle.bmp')
    parser.add_argument('--kernel_size', type=int, default=3)
    option = parser.parse_args()
    main(option)
